﻿package {
	
	// flash.display.*;
	//import flash.events.*;
	
	import lt.uza.utils.*;
	import Gene;
	
	public class Genebank extends Object {
		
		var genes:Array =new Array();

		public function Genebank():void{
			//var t_gene:Gene=new Gene("Null",true);
			//this.push(t_gene);

		}
		/* public function addGene(g:Gene):void{
			 
			 if(this.indexOf(g)==-1){
				var t_gene:Gene= new Gene(g.name,false);
			 	this.push(g);
				if(!g.dominance){
					this.push(t_gene);
				}else{
					t_gene.dominance=!t_gene.dominance;
					t_gene.name=t_gene.name.toUpperCase();
					this.push(t_gene);
				}
			 }
		 }*/
		 public function fill(n:uint=4):void{
			 n++;
			 var randomChars:String = "a b c d e f g h i j k l m n o p q r s t u v x y z"
			 var charArray:Array = randomChars.split(" ");
			 for(var i:uint=0;i<n;i++){
				 //Math.random()
				 addGene(charArray[i],true);
			 }
		 }
		 public function addGene(n:String="A",d:Boolean=true):void{
			var t_gene:Gene=new Gene(n,d);
			if(genes.indexOf(t_gene)==-1){
				genes.push(t_gene);
				var v_gene:Gene= new Gene(n,!d);
				genes.push(v_gene);
			 }
		 }
		 
		 public function printGenes():void{
			 trace("GENES:")
			 for(var i:uint=0;i<genes.length;i++){
				 trace(i+" : " +genes[i].name+" " +genes[i].dominance);
			 }
		 }
	}
}